package com.ruoyi.sl.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.sl.domain.SlOfcabsence;
import com.ruoyi.sl.service.ISlOfcabsenceService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 行政扣发绩效系数Controller
 * 
 * @author admin
 * @date 2024-06-10
 */
@RestController
@RequestMapping("/sl/ofcabsence")
public class SlOfcabsenceController extends BaseController
{
    @Autowired
    private ISlOfcabsenceService slOfcabsenceService;

    /**
     * 查询行政扣发绩效系数列表
     */
    @PreAuthorize("@ss.hasPermi('sl:ofcabsence:list')")
    @GetMapping("/list")
    public TableDataInfo list(SlOfcabsence slOfcabsence)
    {
        startPage();
        List<SlOfcabsence> list = slOfcabsenceService.selectSlOfcabsenceList(slOfcabsence);
        return getDataTable(list);
    }

    /**
     * 导出行政扣发绩效系数列表
     */
    @PreAuthorize("@ss.hasPermi('sl:ofcabsence:export')")
    @Log(title = "行政扣发绩效系数", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, SlOfcabsence slOfcabsence)
    {
        List<SlOfcabsence> list = slOfcabsenceService.selectSlOfcabsenceList(slOfcabsence);
        ExcelUtil<SlOfcabsence> util = new ExcelUtil<SlOfcabsence>(SlOfcabsence.class);
        util.exportExcel(response, list, "行政扣发绩效系数数据");
    }

    /**
     * 获取行政扣发绩效系数详细信息
     */
    @PreAuthorize("@ss.hasPermi('sl:ofcabsence:query')")
    @GetMapping(value = "/{ofcabsenceId}")
    public AjaxResult getInfo(@PathVariable("ofcabsenceId") Long ofcabsenceId)
    {
        return success(slOfcabsenceService.selectSlOfcabsenceByOfcabsenceId(ofcabsenceId));
    }

    /**
     * 新增行政扣发绩效系数
     */
    @PreAuthorize("@ss.hasPermi('sl:ofcabsence:add')")
    @Log(title = "行政扣发绩效系数", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody SlOfcabsence slOfcabsence)
    {
        slOfcabsence.setCreateBy(getUsername());
        return toAjax(slOfcabsenceService.insertSlOfcabsence(slOfcabsence));
    }

    /**
     * 修改行政扣发绩效系数
     */
    @PreAuthorize("@ss.hasPermi('sl:ofcabsence:edit')")
    @Log(title = "行政扣发绩效系数", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody SlOfcabsence slOfcabsence)
    {
        slOfcabsence.setUpdateBy(getUsername());
        return toAjax(slOfcabsenceService.updateSlOfcabsence(slOfcabsence));
    }

    /**
     * 删除行政扣发绩效系数
     */
    @PreAuthorize("@ss.hasPermi('sl:ofcabsence:remove')")
    @Log(title = "行政扣发绩效系数", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ofcabsenceIds}")
    public AjaxResult remove(@PathVariable Long[] ofcabsenceIds)
    {
        return toAjax(slOfcabsenceService.deleteSlOfcabsenceByOfcabsenceIds(ofcabsenceIds));
    }
}
